/**
 * 用户列表相关接口
 */
import request from '@/utils/request.js'

/**
 * 查询分页
 */
export const getList = (current, limit, search) => {
  return request({
    url: '/system/user/list',
    method: 'GET',
    params: {
      ...search,
      current,
      limit
    },
  })
}

/**
 * 删除
 */
export const remove = (ids) => {
  return request({
    url: "/user/remove",
    method: 'DELETE',
    params: {
      ids
    }
  })
}

/**
 * 重置用户密码
 */
export const resetPassword = (ids) => {
  return request({
    url: "/system/user/resetPassword",
    method: 'PUT',
    params: {
      ids
    }
  })
}

/**
 * 修改
 */
export const update = (row) => {
  return request({
    url: '/system/user/update',
    method: 'PUT',
    data: row,
  })
}

/**
 * 修改
 */
export const updateUserInfo = (row) => {
  return request({
    url: '/system/user/update/info',
    method: 'PUT',
    data: row,
  })
}

/**
* 获取详情数据
*/
export const getNotice = (id) => {
  return request({
    url: `/system/user/userInfo/${id}`,
    method: 'GET',
  })
}

/**
* 添加数据
*/
export const add = (row) => {
  return request({
    url: '/system/user',
    method: 'POST',
    data: row,
  })
}

/**
 * 修改用户头
 */
export function updateAvatar(url) {
  return request({
    url: '/system/user/avatar',
    method: 'PUT',
    data: {
      url
    },
  })
}

/**
 * 修改用密码
 */
export function updatePassword(password, checkPassword) {
  return request({
    url: '/system/user/update/password',
    method: 'PUT',
    data: {
      password, checkPassword
    },
  })
}

/**
 * 数据导出
 */
export const exportList = () => {
  return request({
    url: '/system/user/export',
    method: 'get',
    responseType: 'blob',
  })
}

/**
 * 密码重置
 */
export const resetPwd = (id) => {
  return request({
    url: "/user/resetPwd/" + id,
    method: "PUT"
  })
}

/**
 * 获取用户 select 数据
 */
export const getUserTree = () => {
  return request({
    url: "/system/user/userTree"
  })
}

/**
 * 修改用户状态
 */
export const updateStatus = (userId, status) => {
  return request({
    url: "/system/user/update/status",
    method: "PUT",
    data: {
      userId, status
    }
  })
}